package springinpractice.ch2.model;

import java.math.BigDecimal;
import java.util.*;

import javax.persistence.*;

import org.hibernate.annotations.CollectionOfElements;

/*
 * @author	Willie Wheeler John Wheeler and Zeeshan Maqbool
 * Book		'Spring In Practice' [Book written by Willie Wheeler and John Wheeler]
 * 
 */

@Entity
@Table(name = "employees")
public class Employee
{
	private Long emp_id;


	private String emp_name;
	private BigDecimal salary;
	private String title;
	private Date hiredOn;
	//private Set<Email> emails = new HashSet<Email>();
	//private Long department_id;
	private Department department;

	public Employee(String name, String title, BigDecimal salary,Date hired_On)
	{
		this.emp_name = name;
		this.title = title;
		this.salary = salary;
		this.hiredOn = hired_On;
	}

	public Employee()
	{
		// TODO Auto-generated constructor stub
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getEmp_id()
	{
		return emp_id;
	}

	public void setEmp_id(Long empId)
	{
		emp_id = empId;
	}
	
	public String getEmp_name()
	{
		return emp_name;
	}

	public void setEmp_name(String name)
	{
		this.emp_name = name;
	}

	public BigDecimal getSalary()
	{
		return salary;
	}

	public void setSalary(BigDecimal salary)
	{
		this.salary = salary;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	@Column(name = "hired_on")
	public Date getHiredOn()
	{
		return hiredOn;
	}

	public void setHiredOn(Date hiredOn)
	{
		this.hiredOn = hiredOn;
	}

	/*
	@CollectionOfElements
	@JoinTable(name = "emails", joinColumns = @JoinColumn(name = "employee_id"))
	//@Column(name = "address")
	public Set<Email> getEmails()
	{
		return emails;
	}

	public void setEmails(Set<Email> emails)
	{
		this.emails = emails;
	}
	*/
	
	/*public Long getDepartment_id() 
	{
		return department_id;
	}
	
	public void setDepartment_id(Long dept_id)
	{
		// TODO Auto-generated method stub
		this.department_id = dept_id;
	}
	*/
	
	//@ManyToOne(targetEntity = Department.class)
	//@JoinColumn(name = "dept_id")
	@ManyToOne(cascade = CascadeType.ALL)
	public Department getDepartment()
	{
		return this.department;
	}
	public void setDepartment(Department department)
	{
		// TODO Auto-generated method stub
		this.department = department;
	}
}
